//二维树状数组 - 单点修改 + 区间查询
//类比一维树状数组即可
#include <iostream>
using namespace std;
#define lowbit(x) (x & -x)
typedef long long ll;
const int N = 1e4 + 200;
int n, m;
ll s[N][N];

//[x, y]位置增加k
void modify(int x, int y, ll k)
{
    for(int i = x; i <= n; i += lowbit(i))
        for(int j = y; j <= m; j += lowbit(j))
            s[i][j] += k;
}

//查询[1, 1] -> [x, y]区间的和
ll query(int x, int y)
{
    ll sum = 0;
    for(int i = x; i; i -= lowbit(i))
        for(int j = y; j; j -= lowbit(j))
            sum += s[i][j];
    return sum;
}

int main()
{
    cin >> n >> m;
    int op, a, b;
    ll c, d;
    while(cin >> op >> a >> b >> c)
    {
        if(op == 1)
        {
            modify(a, b, c);
        }
        else
        {
            cin >> d;
            cout << query(c, d) - query(a - 1, d) - query(c, b - 1) + query(a - 1, b - 1) << endl;
        }
    }
    return 0;
}